package org.example.service;

import jakarta.annotation.Resource;
import org.example.dao.EmpDao;
import org.example.pojo.Emp;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author TonySong
 * @date 2024/4/26 0026
 * @time 9:51
 */
@Service
public class EmpService implements IEmpService{

    @Resource
    private EmpDao empDao;
    @Override
    public List<Emp> getAllEmps() {
        return this.empDao.findAll();
    }

    @Override
    public Emp getEmpById(Long id) {
        return this.empDao.findById(id).get();
    }

    @Override
    public void saveEmp(Emp emp) {
        this.empDao.saveAndFlush(emp);
    }

    @Override
    public void deleteEmp(Long id) {
           this.empDao.deleteById(id);
    }
}
